home *** CD-ROM | disk | FTP | other *** search
- //____________________________________________________________
- // SpeechChannelIntro.c
- //
- // Copyright © Dan Parks Sydow, 1995
- // From the book:
- // "Graphics and Sound Programming Techniques for the Mac",
- // M&T Books, 1995
-
-
- //____________________________________________________________
-
- #include <Speech.h>
-
-
- //____________________________________________________________
-
- void InitializeToolbox( void );
- Boolean IsSpeechAvailable( void );
- SpeechChannel OpenOneSpeechChannel( void );
-
-
- //____________________________________________________________
-
- void main( void )
- {
- OSErr theError;
- Boolean speechPresent;
- SpeechChannel theChannel;
- Str255 theString = "\pUsing my own speech channel";
-
- InitializeToolbox();
-
- speechPresent = IsSpeechAvailable();
- if ( speechPresent == false )
- ExitToShell();
-
- theChannel = OpenOneSpeechChannel();
- if ( theChannel == nil )
- ExitToShell();
-
- theError = SpeakText( theChannel, (Ptr)(theString + 1), theString[0] );
- if ( theError != noErr )
- ExitToShell();
-
- while ( SpeechBusy() == true )
- ;
-
- theError = DisposeSpeechChannel( theChannel );
- if ( theError != noErr )
- ExitToShell();
- }
-
-
- //____________________________________________________________
-
- SpeechChannel OpenOneSpeechChannel( void )
- {
- SpeechChannel theChannel;
- OSErr theError;
-
- theError = NewSpeechChannel( nil, &theChannel );
-
- if ( theError != noErr )
- {
- theError = DisposeSpeechChannel( theChannel );
- theChannel = nil;
- }
-
- return ( theChannel );
- }
-
-
- //____________________________________________________________
-
- Boolean IsSpeechAvailable( void )
- {
- OSErr theError;
- long theResult;
- Boolean speechAvail;
-
- theError = Gestalt( gestaltSpeechAttr, &theResult );
- if ( theError != noErr )
- ExitToShell();
-
- speechAvail = theResult & ( 1 << gestaltSpeechMgrPresent );
- if ( speechAvail > 0 )
- return ( true );
- else
- return ( false );
- }
-
-
- //____________________________________________________________
-
- void InitializeToolbox( void )
- {
- InitGraf( &qd.thePort );
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs( 0L );
- FlushEvents( everyEvent, 0 );
- InitCursor();
- }
-
-
-
-